1. /* sdcpi.cpp by K.Tsuru */
  2. // function ID 3523 DRADIX
  3. /*************
  4. constant pi
  5. In header "snmath.h" the function prototype is given below
  6. --------
  7. SDouble Pi(const SDouble* pi = NULL, SDouble (*pfCalcFunc)() = SNPi);
  8. --------
  9. Remade at version 2.30.
  10. **************/
  11. #ifndef SN_H
  12. #include "sn.h"
  13. #endif
  14. static SDouble* pi = NULL; //keep in the static memory
  15. static uint piSize = 0;
  16. void PiFree(){ //free the memory of pi
  17. if(piSize == 0) return;
  18. delete pi; pi = NULL; piSize = 0;
  19. }
  20. uint PiSize() { return piSize; }
  21. SDouble Pi(const SDouble* userPi, SDouble (*pfCalcFunc)()){
  22. // "new" must been done here.
  23. if(pi == NULL) pi = new SDouble;
  24. uint curMaxSize = pi->MaxSize(); // current max size
  25. if( piSize < curMaxSize ){
  26. #if UsesSNConstantFile
  27. if(userPi == NULL){ //called by default argument
  28. int enough;
  29. /**********************************************************************************
  30. UpdateConstantFile() recursively calls this function Pi() via SetConstByFile()
  31. of which userE != NULL, then does not come here and processing below has been
  32. done.
  33. **********************************************************************************/
  34. enough = UpdateConstantFile(Pi_FILE, Pi, pfCalcFunc, curMaxSize);
  35. if(enough != NO_SNC_FILE) return *pi;
  36. }
  37. #endif
  38. pi->ShowMessage("Evaluating Pi() now.....");
  39. EntryConst(userPi, pi, pfCalcFunc, &piSize);
  40. pi->ShowMessage(" Finished.\n"); // ver. 2.17
  41. piSize = curMaxSize;
  42. }
  43. return *pi;
  44. }

sdcpi.cpp : last modifiled at 2017/07/15 15:52:56(1,497 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).